home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 12, No. 09 (1991-09)(MindCraft Publishing)(Side A).zip
/
Nibble Volume 12, No. 09 (1991-09)(MindCraft Publishing)(Side A).po
/
OFFLINE.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
9KB
|
264 lines
; OFFLINE by George Powell
; Copyright (C) 1991, MindCraft Publ., Lincoln, MA 01773
ORG $2000 ; start at $2000
MLI EQU $BF00 ; Machine Language Interface
FILENAME EQU $0280 ; filename buffer
COUT EQU $FDED ; character out
DEVCNT EQU $BF31 ; number of active devices
DEVLST EQU $BF32 ; list of active devices
HOME EQU $FC58 ; clear the screen
NORM EQU $FE93 ; set 40 column normal mode
SERR EQU $BF0F ; prodos error storage
PHEX EQU $FDDA ; print hex number
MONITOR EQU $FF65 ; monitor
KEY EQU $C000
CH EQU $0024 ; horizontal position of cursor
JMP MOVE1 ; jump over the filename buffer
DFC $EE,$EE ; signifies a pathname buffer follows
DFC 65 ; max length of our buffer
RUNTHIS DFC 12 ; length of filename in buffer
ASC 'BASIC.SYSTEM '
ASC ' '
ASC ' ' ; room for 64 bytes above
MOVE1 LDY #$00
MOVE LDA ZAP,Y ; move program to $1000
STA $1000,Y
LDA ZAP+256,Y
STA $1100,Y
LDA ZAP+512,Y
STA $1200,Y
INY
BNE MOVE
JMP SCAN1 ; go to the relocated code
ZAP ORG $1000 ; new originate address
SCAN1 LDA #OOPS ; fix reset vector
STA $3F2 ; to point to the prodos selector call
LDA #OOPS/
STA $3F3
EOR #$A5
STA $3F4
JSR NORM ; set normal 40 column display
JSR HOME ; clear the screen
LDY #$17
LDA #$00
BMAP STA $BF58,Y ; clear out bitmap
DEY
BPL BMAP
LDA #$CF
STA $BF58 ; protect zp,stack, and text
LDA #$01
STA $BF6F ; protect MLI global page
JSR PTXT ; print the title
ASC " OFFLINE"
DFC $8D,$8D
ASC " By"
DFC $8D,$8D
ASC " George Powell"
DFC $8D,$8D
ASC " Copyright (C) 1991"
DFC $8D,$8D
ASC " MindCraft Publ. Corp."
DFC $8D,$8D
ASC " Lincoln, MA 01773"
DFC $8D
ASC " "
DFC $8D,$8D
ASC " Active Devices"
DFC $8D
ASC " =============="
DFC $8D,0
LDY #$FF ; counter for number
STY NUMGOOD ; of good devices
LDY #14 ; counter for devices to try
STY CNTR
SCAN DEC CNTR
BMI WEDONE ; our counter is less than 0
LDY CNTR ; position in table
LDA ALLTBL,Y ; get device number
STA O_DEV ; set up for MLI ONLINE call
JSR MLI ; make MLI ONLINE call
DFC $C5
ADR O_PARM ; online parm list
BCS SCAN ; its not active so keep going
LDY CNTR ; found a active drive
INC NUMGOOD ; increment number of active ones
LDX NUMGOOD ; get index to active table
LDA O_DEV ; get device number
STA TABLE,X ; store it in the active list
ROR ; divide device number by 16
ROR
ROR
ROR
PHA ; keep it safe
AND #$07 ; mask off slot bits
PHA ; keep it safe
LDA #13
STA CH ; print at center of screen
JSR PTXT ; print slot message
ASC "Slot "
BRK
PLA ; get back slot value off of stack
CLC ; make it into ASCII
ADC #48
JSR COUT ; print slot value
JSR PTXT ; print drive message
ASC " Drive "
BRK
PLA ; get back value from stack
ROR ; put drive bit into position 1
ROR
ROR
AND #$01 ; mask off drive bit
CLC ; make it into ASCII
ADC #49
JSR COUT ; print drive number
LDA #$8D ; print a carriage return
JSR COUT
JMP SCAN ; continue with scanning
WEDONE INC $3F4 ; kill reset vector
LDY NUMGOOD ; how many active devices
STY DEVCNT ; tell PRODOS
WDLP LDA TABLE,Y ; get active devices
STA DEVLST,Y ; tell PRODOS about the devices
DEY
BPL WDLP
DEC $3F4 ; safe to hit reset again
JSR MLI ; get file info
DFC $C4
ADR IPARM ; parm table for get info
BCS OOPS ; ERROR
LDA FTYPE ; get filetype
CMP #$FF ; is it a SYS file?
BNE OOPS ; no, don't execute it
JSR MLI ; open launch pathname
DFC $C8
ADR O_TABLE
BCS OOPS ; ERROR
LDA O_REF ; get referance number
STA R_REF ; let read call know
JSR MLI ; read in the file
DFC $CA
ADR R_TABLE
BCS OOPS ; ERROR
JSR MLI ; close the file
DFC $CC
ADR C_TABLE
BCS OOPS ; ERROR
LDA KEY ; check keyboard
CMP #155 ; is it escape (27+128)
BEQ OOPS ; yes, use PRODOS selector
JMP $2000 ; execute the program just loaded
OOPS JSR MLI ; a error in launching the program
DFC $CC ; so use the PRODOS selector
ADR C_TABLE
JSR MLI
DFC $65
ADR Q_TABLE
; if could not execute prodos selector
; tell the user and why
JSR PTXT
DFC $8D,$8D,$87,$87
ASC "PRODOS ERROR..CODE= "
BRK
LDA SERR ; MLI error code storage
JSR PHEX ; print error code
JMP MONITOR ; go to the monitor
PTXT PLA ; imbedded text printing
STA LDD+1
PLA
STA LDD+2
PTXT1B INC LDD+1
BNE LDD
INC LDD+2
LDD LDA $FFFF ; self modyfying code
BEQ PTXTDUN ; 0 is end of text marker
JSR COUT ; print it
JMP PTXT1B ; is there more to print?
PTXTDUN LDA LDD+2 ; get address and
PHA ; fix the stack
LDA LDD+1
PHA
RTS ; continue with program after the 0
; ALLTBL is the list of all
; possible device values
; DRIVE 1 DRIVE 2
ALLTBL DFC $10,$90 ; SLOT 1
DFC $20,$A0 ; SLOT 2
DFC $30,$BF ; SLOT 3
DFC $40,$C0 ; SLOT 4
DFC $50,$D0 ; SLOT 5
DFC $60,$E0 ; SLOT 6
DFC $70,$F0 ; SLOT 7
; NOTE: the $bf in 3,2 is so that programs
; that use /RAM will see it as a RAMDISK.
;
NUMGOOD DFC 0 ;number of good devices
TABLE DFC 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
CNTR DFC 0 ; general purpose counter
O_TABLE DFC 3 ; open parm table
ADR RUNTHIS ; open pathname
ADR $1C00 ; input buffer at $1C00
O_REF DFC 0 ; open reference number
R_TABLE DFC 4 ; read parm table
R_REF DFC 0 ; read reference number
ADR $2000 ; where to read it to
ADR $FFFF ; how much to read..
DFC 0,0 ; how much actually read
C_TABLE DFC 1 ; close parm table
DFC 0 ; close reference number
Q_TABLE DFC 4,0,0,0,0,0,0 ; prodos selector table
O_PARM DFC 2 ; online parm table
O_DEV DFC 0 ; device to check
ADR FILENAME ; where to put filename
IPARM DFC 10 ; get file info parm table
ADR RUNTHIS ; path of file
DFC 0
FTYPE DFC 0 ; file type
DFC 0,0,0,0,0,0,0,0,0,0,0,0,0
E